package com.rongc.client.freight.base.view.activity;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.rongc.client.core.utils.SystemUtil;
import com.rongc.client.freight.R;
import com.rongc.client.freight.base.BaseActivity;
import com.rongc.client.freight.base.model.BaseDic;
import com.rongc.client.freight.base.model.DicsBean;
import com.rongc.client.freight.base.model.DicsBean.DicBean;
import com.rongc.client.freight.base.view.adapter.RecyclerBaseAdapter;
import com.rongc.client.freight.base.view.widget.SpaceItemDecoration;
import com.rongc.client.freight.base.view.adapter.RecyclerLengthAdapter;

import java.util.List;

import butterknife.Bind;
/**
 * Created by ccqx on 2017/7/1.
 */

public class CarLengthActivity extends BaseActivity {
    @Bind(R.id.recycler)
    RecyclerView mRecyclerView;
    RecyclerLengthAdapter modelAdapter;

    List<DicBean> datas;

    @Override
    public void initView() {
        initToolbar(R.string.supply_length_title);

        datas = DicsBean.load(BaseDic.DicsType.LENGTH_TYPE).getDics();

        modelAdapter = new RecyclerLengthAdapter(this,datas);
        mRecyclerView.setLayoutManager(new GridLayoutManager(this,4));
        mRecyclerView.addItemDecoration(new SpaceItemDecoration(SystemUtil.dip2px(this, 6f), SystemUtil.dip2px(this, 6f)));
        mRecyclerView.setAdapter(modelAdapter);

        modelAdapter.setOnItemClickListener(new RecyclerBaseAdapter.OnItemClickListener<DicBean>() {
            @Override
            public void onItemClick(View view, int position, DicBean data) {
                Intent intent = new Intent();
                intent.putExtra("data",data);
                setResult(RESULT_OK,intent);
                finish();
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public int getLayoutId() {
        return R.layout.universal_recycler;
    }
}
